package com.example.demo.query;

import com.coxautodev.graphql.tools.GraphQLQueryResolver;
import com.example.demo.dto.Author;
import com.example.demo.dto.Book;
import com.example.demo.service.FindBooksService;
import lombok.var;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author Allen.Lv
 * @Description 解释器
 * @Date 15:01 2019/2/21
 * @Desc: Coding Happy!
 **/
@Component
public class BookQueryResolver implements GraphQLQueryResolver {

    @Autowired
    FindBooksService findBooksService;

    public List<Book> findBooks() {
        var books = findBooksService.findBooks();
        List<Book> bookList = new ArrayList<Book>();
        bookList.addAll(books);
        return bookList;
    }


}
